{% extends 'reports.html' %}

{% block header %}Reports: Library status{% endblock %}

{% block report %}
<form action="." method="POST">
    {% include "reports/date_controls.html" %}

    <div style='margin-top: 1em'>
            <table class='booklist'>
                <tr>
                    <th rowspan='2'>Title
                      <br>
                      <input type="submit" name="btn_sort_title" value="^" title="Ascending"/>
                      <input type="submit" name="btn_sort_-title" value="v" title="Descending"/></th>
                    <th rowspan='2'>Location
                      <br>
                      <input type="submit" name="btn_sort_location" value="^" title="Ascending"/>
                      <input type="submit" name="btn_sort_-location" value="v" title="Descending"/></th>
                    <th rowspan='2'>Shelf mark
                      <br>
                      <input type="submit" name="btn_sort_shelf_mark" value="^" title="Ascending"/>
                      <input type="submit" name="btn_sort_-shelf_mark" value="v" title="Descending"/></th>
                    <th rowspan='2'>Status
                      <br>
                      <input type="submit" name="btn_sort_status" value="^" title="Ascending"/>
                      <input type="submit" name="btn_sort_-status" value="v" title="Descending"/></th>
                    <th colspan='3'>Last time rented</th>
                </tr>
                <tr>
                    <td>For whom
                      <br>
                      <input type="submit" name="btn_sort_for_whom" value="^" title="Ascending"/>
                      <input type="submit" name="btn_sort_-for_whom" value="v" title="Descending"/></td>
                    <td><span title="When rental stated">When</span>
                      <br>
                      <input type="submit" name="btn_sort_when" value="^" title="Ascending"/>
                      <input type="submit" name="btn_sort_-when" value="v" title="Descending"/></td>
                    <td>Librarian
                      <br>
                      <input type="submit" name="btn_sort_librarian" value="^" title="Ascending"/>
                      <input type="submit" name="btn_sort_-librarian" value="v" title="Descending"/></td>
                </tr>
                {% for book in report %}
                <tr>
                    <td>{{ book.title }}</td>
                    <td>{{ book.location }}</td>
                    <td>{{ book.shelf_mark }}</td>
                    <td>{{ book.status }}</td>
                    {% if book.not_rented_yet %}
                        <td colspan='3'>Not rented yet</td>
                    {% else %}
                        <td>{{ book.for_whom }}</td>
                        <td>{{ book.when }}</td>
                        <td>{{ book.by_whom }}</td>
                    {% endif %}
                </tr>
                {% endfor %}
            </table>
    </div>
</form>
{% endblock %}
